@@ -1,5 +1,55 @@
# This file documents the revision history for Perl extension Catalyst.
+5.80028 2010-09-28 20:49:00
+
+ Bug fixes:
+ - use Class::MOP in Catalyst::Utils.
+
+ - Do not keep a reference to a closed over context in ctx_request, allowing
+ the caller to dispose of the request context at their leisure.
+
+ - Changes to be compatible with bleadperl
+
+5.80027 2010-09-01 22:14:00
+
+ Bug fixes:
+ - Fix an issue with newly added test cases which depended on Catalyst::Action::RenderView
+
+5.80026 2010-09-01 15:14:00
+
+ Bug fixes:
+ - Fix so that CATALYST_EXCEPTION_CLASS in MyApp is always respected by
+ not loading Catalyst::Exception in Utils.pm BEGIN, because some Scripts::*
+ load Utils before MyApp.pm
+
+ - Fix warnings with new Moose versions about "excludes" during role
+ application
+
+ - Fix warning from MooseX::Getopt regarding duplicate "help" aliases.
+
+ - parse_on_demand fixed when used in conjunction with debug mode.
+ A regression was introduced in 5.80022 which would cause the body
+ to always be parsed for logging at the end of the request when in
+ debug mode. This has been fixed so that if the body has not been parsed
+ by the time the request is logged, then the body is omitted.
+
+ - Fix show_internal_actions config setting producing warnings in debug
+ mode (RT#59738)
+
+ - Make Catalyst::Test::local_request() set the response base from base href
+ in the returned document so that links can be resolved correctly by
+ Test::WWW::Mechanize::Catalyst
+
+ Refactoring:
+ - moved component name sort that happens in setup_components to
+ locate_components to allow methods to wrap around locate_components
+
+ Documentation:
+ - Fix some typos
+
+ - Advertise Catalyst::Plugin::SmartURI
+
+
5.80025 2010-07-29 01:50:00
New features:
@@ -14,6 +64,8 @@
- Fix controllers with no method attributes (where the action definitions
are entirely contained in config). RT#58057
- Fix running as a CGI under IIS at non-root locations.
+ - Fix warning about "excludes" during role application
+ - Fix warning from MooseX::Getopt regarding duplicate "help" aliases
Documentation:
- Fix missing - in the docs when describing the --mechanize option at one
@@ -74,6 +74,7 @@ t/aggregate/custom_live_component_controller_action_auto_doublebug.t
t/aggregate/custom_live_path_bug.t
t/aggregate/deprecated_test_import.t
t/aggregate/error_page_dump.t
+t/aggregate/live__component_controller_action_chained2.t
t/aggregate/live_component_controller_action_action.t
t/aggregate/live_component_controller_action_auto.t
t/aggregate/live_component_controller_action_begin.t
@@ -196,6 +197,8 @@ t/lib/Catalyst/Script/Bar.pm
t/lib/Catalyst/Script/Baz.pm
t/lib/Catalyst/Script/CompileTest.pm
t/lib/CDICompatTestPlugin.pm
+t/lib/ChainedActionsApp.pm
+t/lib/ChainedActionsApp/Controller/Root.pm
t/lib/DeprecatedActionsInAppClassTestApp.pm
t/lib/DeprecatedTestApp.pm
t/lib/DeprecatedTestApp/C/Root.pm
@@ -325,6 +328,8 @@ t/lib/TestAppOneView/View/Dummy.pm
t/lib/TestAppPathBug.pm
t/lib/TestAppPluginWithConstructor.pm
t/lib/TestAppPluginWithConstructor/Controller/Root.pm
+t/lib/TestAppShowInternalActions.pm
+t/lib/TestAppShowInternalActions/Controller/Root.pm
t/lib/TestAppStats.pm
t/lib/TestAppStats/Controller/Root.pm
t/lib/TestAppToTestScripts.pm
@@ -335,6 +340,7 @@ t/lib/TestPluginWithConstructor.pm
t/live_catalyst_test.t
t/live_component_controller_context_closure.t
t/live_fork.t
+t/live_show_internal_actions_warnings.t
t/live_stats.t
t/optional_apache-cgi-rewrite.pl
t/optional_apache-cgi.pl
@@ -30,6 +30,7 @@ requires:
Data::Dump: 0
Data::OptList: 0
HTML::Entities: 0
+ HTML::HeadParser: 0
HTTP::Body: 1.06
HTTP::Headers: 1.64
HTTP::Request: 5.814
@@ -41,7 +42,7 @@ requires:
Module::Pluggable: 3.9
Moose: 1.03
MooseX::Emulate::Class::Accessor::Fast: 0.00903
- MooseX::Getopt: 0.25
+ MooseX::Getopt: 0.30
MooseX::MethodAttributes::Inheritable: 0.19
MooseX::Role::WithOverloading: 0.05
MooseX::Types: 0
@@ -68,4 +69,4 @@ resources:
homepage: http://dev.catalyst.perl.org/
license: http://dev.perl.org/licenses/
repository: http://dev.catalyst.perl.org/repos/Catalyst/Catalyst-Runtime/
-version: 5.80025
+version: 5.80028
@@ -28,6 +28,7 @@ requires 'CGI::Simple::Cookie' => '1.109';
requires 'Data::Dump';
requires 'Data::OptList';
requires 'HTML::Entities';
+requires 'HTML::HeadParser';
requires 'HTTP::Body' => '1.06'; # ->cleanup(1)
requires 'HTTP::Headers' => '1.64';
requires 'HTTP::Request' => '5.814';
@@ -46,7 +47,7 @@ requires 'URI' => '1.35';
requires 'Task::Weaken';
requires 'Text::Balanced'; # core in 5.8.x but mentioned for completeness
requires 'MRO::Compat';
-requires 'MooseX::Getopt' => '0.25';
+requires 'MooseX::Getopt' => '0.30';
requires 'MooseX::Types';
requires 'MooseX::Types::Common::Numeric';
requires 'String::RewritePrefix' => '0.004'; # Catalyst::Utils::resolve_namespace
@@ -65,7 +66,7 @@ else {
grep { $_ ne 't/aggregate.t' }
map { glob } qw[t/*.t t/aggregate/*.t];
}
-author_requires 'CatalystX::LeakChecker', '0.05'; # Skipped if this isn't installed
+author_requires 'CatalystX::LeakChecker', '0.05';
author_requires 'File::Copy::Recursive'; # For http server test
author_tests 't/author';
@@ -7,7 +7,7 @@ BEGIN { require 5.008004; }
# Remember to update this in Catalyst as well!
-our $VERSION = '5.80025';
+our $VERSION = '5.80028';
=head1 NAME
@@ -16,7 +16,7 @@ Catalyst::Script::CGI - The CGI Catalyst Script
myapp_cgi.pl [options]
Options:
- -h --help display this help and exits
+ -? --help display this help and exits
=head1 DESCRIPTION
@@ -13,8 +13,6 @@ use namespace::autoclean;
with 'Catalyst::ScriptRole';
-__PACKAGE__->meta->get_attribute('help')->cmd_aliases('?');
-
has debug => (
traits => [qw(Getopt)],
cmd_aliases => 'd',
@@ -6,7 +6,7 @@ use MooseX::Getopt;
use namespace::autoclean;
with 'MooseX::Getopt' => {
- excludes => [qw/
+ -excludes => [qw/
_getopt_spec_warnings
_getopt_spec_exception
_getopt_full_usage
@@ -20,14 +20,6 @@ has application_name => (
required => 1,
);
-has help => (
- traits => ['Getopt'],
- isa => Bool,
- is => 'ro',
- documentation => 'Display this help and exit',
- cmd_aliases => ['?', 'h'],
-);
-
sub _getopt_spec_exception {}
sub _getopt_spec_warnings {
@@ -41,11 +33,6 @@ sub _getopt_full_usage {
exit 0;
}
-before run => sub {
- my $self = shift;
- $self->_getopt_full_usage if $self->help;
-};
-
sub run {
my $self = shift;
$self->_run_application;
@@ -44,7 +44,7 @@ my $build_exports = sub {
### place holder for $c after the request finishes; reset every time
### requests are done.
- my $c;
+ my $ctx_closed_over;
### hook into 'dispatch' -- the function gets called after all plugins
### have done their work, and it's an easy place to capture $c.
@@ -52,7 +52,7 @@ my $build_exports = sub {
my $meta = Class::MOP::get_metaclass_by_name($class);
$meta->make_mutable;
$meta->add_after_method_modifier( "dispatch", sub {
- $c = shift;
+ $ctx_closed_over = shift;
});
$meta->make_immutable( replace_constructor => 1 );
Class::C3::reinitialize(); # Fixes RT#46459, I've failed to write a test for how/why, but it does.
@@ -60,8 +60,18 @@ my $build_exports = sub {
### we've already stopped it from doing remote requests above.
my $res = $request->( @_ );
+ # Make sure not to leave a reference $ctx hanging around.
+ # This means that the context will go out of scope as soon as the
+ # caller disposes of it, rather than waiting till the next time
+ # that ctx_request is called. This can be important if your $ctx
+ # ends up with a reference to a shared resource or lock (for example)
+ # which you want to clean up in test teardown - if the $ctx is still
+ # closed over then you're stuffed...
+ my $ctx = $ctx_closed_over;
+ undef $ctx_closed_over;
+
### return both values
- return ( $res, $c );
+ return ( $res, $ctx );
};
return {
@@ -239,6 +249,21 @@ sub local_request {
my $response = $cgi->restore->response;
$response->request( $request );
+
+ # HTML head parsing based on LWP::UserAgent
+
+ require HTML::HeadParser;
+
+ my $parser = HTML::HeadParser->new();
+ $parser->xml_mode(1) if $response->content_is_xhtml;
+ $parser->utf8_mode(1) if $] >= 5.008 && $HTML::Parser::VERSION >= 3.40;
+
+ $parser->parse( $response->content );
+ my $h = $parser->header;
+ for my $f ( $h->header_field_names ) {
+ $response->init_header( $f, [ $h->header($f) ] );
+ }
+
return $response;
}
@@ -1,14 +1,13 @@
package Catalyst::Utils;
use strict;
-use Catalyst::Exception;
use File::Spec;
use HTTP::Request;
use Path::Class;
use URI;
use Carp qw/croak/;
use Cwd;
-
+use Class::MOP;
use String::RewritePrefix;
use namespace::clean;
@@ -140,6 +139,13 @@ sub class2tempdir {
eval { $tmpdir->mkpath };
if ($@) {
+ # don't load Catalyst::Exception as a BEGIN in Utils,
+ # because Utils often gets loaded before MyApp.pm, and if
+ # Catalyst::Exception is loaded before MyApp.pm, it does
+ # not honor setting
+ # $Catalyst::Exception::CATALYST_EXCEPTION_CLASS in
+ # MyApp.pm
+ require Catalyst::Exception;
Catalyst::Exception->throw(
message => qq/Couldn't create tmpdir '$tmpdir', "$@"/ );
}
@@ -79,7 +79,7 @@ __PACKAGE__->stats_class('Catalyst::Stats');
# Remember to update this in Catalyst::Runtime as well!
-our $VERSION = '5.80025';
+our $VERSION = '5.80028';
sub import {
my ( $class, @arguments ) = @_;
@@ -428,6 +428,10 @@ with localized C<< $c->action >> and C<< $c->namespace >>. Like C<detach>,
C<go> escapes the processing of the current request chain on completion, and
does not return to its caller.
+@arguments are arguments to the final destination of $action. @captures are
+arguments to the intermediate steps, if any, on the way to the final sub of
+$action.
+
=cut
sub go { my $c = shift; $c->dispatcher->go( $c, @_ ) }
@@ -1242,7 +1246,9 @@ sub setup_finalize {
Constructs an absolute L<URI> object based on the application root, the
provided path, and the additional arguments and query parameters provided.
-When used as a string, provides a textual URI.
+When used as a string, provides a textual URI. If you need more flexibility
+than this (i.e. the option to provide relative URIs etc.) see
+L<Catalyst::Plugin::SmartURI>.
If no arguments are provided, the URI for the current action is returned.
To return the current action and also provide @args, use
@@ -1699,7 +1705,7 @@ sub _stats_start_execute {
my $parent = $c->stack->[-1];
# forward, locate the caller
- if ( exists $c->counter->{"$parent"} ) {
+ if ( defined $parent && exists $c->counter->{"$parent"} ) {
$c->stats->profile(
begin => $action,
parent => "$parent" . $c->counter->{"$parent"},
@@ -2148,7 +2154,7 @@ sub log_request {
$c->log->debug("Query keywords are: $keywords");
}
- $c->log_request_parameters( query => $request->query_parameters, body => $request->body_parameters );
+ $c->log_request_parameters( query => $request->query_parameters, $request->_has_body ? (body => $request->body_parameters) : () );
$c->log_request_uploads($request);
}
@@ -2405,8 +2411,7 @@ sub setup_components {
my $config = $class->config->{ setup_components };
- my @comps = sort { length $a <=> length $b }
- $class->locate_components($config);
+ my @comps = $class->locate_components($config);
my %comps = map { $_ => 1 } @comps;
my $deprecatedcatalyst_component_names = grep { /::[CMV]::/ } @comps;
@@ -2461,7 +2466,8 @@ sub locate_components {
%$config
);
- my @comps = $locator->plugins;
+ # XXX think about ditching this sort entirely
+ my @comps = sort { length $a <=> length $b } $locator->plugins;
return @comps;
}
@@ -0,0 +1,22 @@
+use strict;
+use warnings;
+use FindBin qw/$Bin/;
+use lib "$Bin/../lib";
+use Catalyst::Test 'ChainedActionsApp';
+use Test::More;
+
+plan 'skip_all' if $ENV{CATALYST_SERVER}; # This is not TestApp
+
+content_like('/', qr/Application Home Page/, 'Application home');
+content_like('/15/GoldFinger', qr/List project GoldFinger pages/, 'GoldFinger Project Index');
+content_like('/15/GoldFinger/4/007', qr/This is 007 page of GoldFinger project/, '007 page in GoldFinger Project');
+TODO: {
+ local $TODO="Bug on precedence of dispatch order of chained actions.";
+ content_like('/account', qr/New account o login/, 'no account');
+ content_like('/account/ferz', qr/This is account ferz/, 'account');
+ content_like('/account/123', qr/This is account 123/, 'account');
+}
+action_notfound('/c');
+
+done_testing;
+
@@ -12,7 +12,7 @@ use HTTP::Request::Common;
my $content_length;
-foreach my $method qw(HEAD GET) {
+foreach my $method (qw(HEAD GET)) {
my $expected = join( ', ', 1 .. 10 );
my $request = HTTP::Request::Common->can($method)
@@ -15,7 +15,6 @@ use lib "$Bin/../lib";
sub _getopt_full_usage { $help++ }
}
-test('-h');
test('--help');
test('-?');
@@ -33,8 +33,8 @@ sub run_test {
} "new_with_options";
ok $i;
my $saved;
- open( $saved, '<&'. STDIN->fileno )
- or croak("Can't dup stdin: $!");
+ open( $saved, '>&'. STDOUT->fileno )
+ or croak("Can't dup stdout: $!");
open( STDOUT, '>&='. $fh->fileno )
or croak("Can't open stdout: $!");
eval { $i->run };
@@ -5,9 +5,12 @@ use Test::More;
use Pod::Coverage 0.19;
use Test::Pod::Coverage 1.04;
-all_pod_coverage_ok(
- {
- also_private => ['BUILD']
- }
-);
+my @modules = all_modules;
+our @private = ( 'BUILD' );
+foreach my $module (@modules) {
+ local @private = (@private, 'run') if $module =~ /^Catalyst::Script::/;
+ pod_coverage_ok($module, { also_private => \@private });
+}
+
+done_testing;
@@ -4,9 +4,17 @@ use strict;
use warnings;
use FindBin qw/$Bin/;
use lib "$Bin/lib";
-use Test::More tests => 1;
+use Test::More tests => 2;
use Test::Exception;
lives_ok {
require TestAppClassExceptionSimpleTest;
} 'Can load application';
+
+
+lives_ok {
+ Catalyst::Exception->throw
+} 'throw is properly stubbed out';
+
+
+
@@ -0,0 +1,63 @@
+package ChainedActionsApp::Controller::Root;
+use Moose;
+use namespace::autoclean;
+
+BEGIN { extends 'Catalyst::Controller' }
+
+#
+# Sets the actions in this controller to be registered with no prefix
+# so they function identically to actions created in MyApp.pm
+#
+__PACKAGE__->config(namespace => '');
+
+sub setup : Chained('/') PathPart('') CaptureArgs(0) {
+ my ( $self, $c ) = @_;
+ # Common things here are to check for ACL and setup global contexts
+}
+
+sub home : Chained('setup') PathPart('') Args(0) {
+ my($self,$c) = @_;
+ $c->response->body( "Application Home Page" );
+}
+
+sub home_base : Chained('setup') PathPart('') CaptureArgs(2) {
+ my($self,$c,$proj_id,$title) = @_;
+ $c->stash({project_id=>$proj_id, project_title=>$title});
+}
+
+sub hpages : Chained('home_base') PathPart('') Args(0) {
+ my($self,$c) = @_;
+ $c->response->body( "List project " . $c->stash->{project_title} . " pages");
+}
+
+sub hpage : Chained('home_base') PathPart('') Args(2) {
+ my($self,$c,$page_id, $pagetitle) = @_;
+ $c->response->body( "This is $pagetitle page of " . $c->stash->{project_title} . " project" );
+}
+
+sub no_account : Chained('setup') PathPart('account') Args(0) {
+ my($self,$c) = @_;
+ $c->response->body( "New account o login" );
+}
+
+sub account_base : Chained('setup') PathPart('account') CaptureArgs(1) {
+ my($self,$c,$acc_id) = @_;
+ $c->stash({account_id=>$acc_id});
+}
+
+sub account : Chained('account_base') PathPart('') Args(0) {
+ my($self,$c,$acc) = @_;
+ $c->response->body( "This is account " . $c->stash->{account_id} );
+}
+
+sub default : Chained('setup') PathPart('') Args() {
+ my ( $self, $c ) = @_;
+ $c->response->body( 'Page not found' );
+ $c->response->status(404);
+}
+
+sub end : Action {}
+
+__PACKAGE__->meta->make_immutable;
+
+1;
@@ -0,0 +1,21 @@
+package ChainedActionsApp;
+use Moose;
+use namespace::autoclean;
+
+use Catalyst::Runtime 5.80;
+
+use Catalyst qw//;
+
+extends 'Catalyst';
+
+our $VERSION = "0.01";
+$VERSION = eval $VERSION;
+
+__PACKAGE__->config(
+ name => 'ChainedActionsApp',
+ disable_component_regex_fallback => 1,
+);
+
+__PACKAGE__->setup;
+
+1;
@@ -49,6 +49,22 @@ sub recursion_test : Local {
$c->forward( 'recursion_test' );
}
+sub base_href_test : Local {
+ my ( $self, $c ) = @_;
+
+ my $body = <<"EndOfBody";
+<html>
+ <head>
+ <base href="http://www.example.com/">
+ </head>
+ <body>
+ </body>
+</html>
+EndOfBody
+
+ $c->response->body($body);
+}
+
sub end : Private {
my ($self,$c) = @_;
}
@@ -10,6 +10,8 @@ package TestAppClassExceptionSimpleTest;
use strict;
use warnings;
+use Catalyst::Utils; #< some of the scripts use Catalyst::Utils before MyApp.pm
+
BEGIN { $Catalyst::Exception::CATALYST_EXCEPTION_CLASS = 'TestAppClassExceptionSimpleTest::Exception'; }
use Catalyst;
@@ -0,0 +1,19 @@
+package TestAppShowInternalActions::Controller::Root;
+use Moose;
+use namespace::autoclean;
+
+BEGIN { extends 'Catalyst::Controller' }
+
+__PACKAGE__->config(namespace => '');
+
+sub index :Path :Args(0) {
+ my ( $self, $c ) = @_;
+
+ $c->response->body( 'hello world' );
+}
+
+sub end : Action {}
+
+__PACKAGE__->meta->make_immutable;
+
+1;
@@ -0,0 +1,20 @@
+package TestAppShowInternalActions;
+use Moose;
+use namespace::autoclean;
+
+use Catalyst::Runtime 5.80;
+
+use Catalyst qw/ -Debug /; # Debug must remain on for
+ # t/live_show_internal_actions_warnings.t
+
+extends 'Catalyst';
+
+__PACKAGE__->config(
+ name => 'TestAppShowInternalActions',
+ disable_component_resolution_regex_fallback => 1,
+ show_internal_actions => 1,
+);
+
+__PACKAGE__->setup();
+
+1;
@@ -3,7 +3,7 @@ use lib "$FindBin::Bin/lib";
use Catalyst::Test 'TestApp', {default_host => 'default.com'};
use Catalyst::Request;
-use Test::More tests => 8;
+use Test::More tests => 9;
content_like('/',qr/root/,'content check');
action_ok('/','Action ok ok','normal action ok');
@@ -11,6 +11,12 @@ action_redirect('/engine/response/redirect/one','redirect check');
action_notfound('/engine/response/status/s404','notfound check');
contenttype_is('/action/local/one','text/plain','Contenttype check');
+### local_request() was not setting response base from base href
+{
+ my $response = request('/base_href_test');
+ is( $response->base, 'http://www.example.com/', 'response base set from base href');
+}
+
my $creq;
my $req = '/dump/request';
@@ -0,0 +1,25 @@
+use strict;
+use warnings;
+use FindBin '$Bin';
+use lib "$Bin/lib";
+use Test::More;
+use File::Spec;
+BEGIN { # Shut up debug output, app needs debug on for the issue to
+ # appear, but we don't want the spraff to the screen
+
+ my $devnull = File::Spec->devnull;
+ open my $fh, '>', $devnull or die "Cannot write to $devnull: $!";
+
+ *STDERR = $fh;
+}
+
+use Catalyst::Test 'TestAppShowInternalActions';
+
+my $last_warning;
+{
+ local $SIG{__WARN__} = sub { $last_warning = shift };
+ my $res = get('/');
+}
+is( $last_warning, undef, 'there should be no warnings about uninitialized value' );
+
+done_testing;
@@ -13,17 +13,14 @@ use FindBin;
use LWP::Simple;
use IO::Socket;
use IPC::Open3;
-use Catalyst::Engine::HTTP::Restarter::Watcher;
use Time::HiRes qw/sleep/;
-eval "use Catalyst::Devel 1.0;";
+eval {require Catalyst::Devel; Catalyst::Devel->VERSION(1.0);};
plan skip_all => 'Catalyst::Devel required' if $@;
plan skip_all => 'Catalyst::Devel >= 1.04 required' if $Catalyst::Devel::VERSION <= 1.03;
eval "use File::Copy::Recursive";
plan skip_all => 'File::Copy::Recursive required' if $@;
-plan tests => 120;
-
my $tmpdir = "$FindBin::Bin/../t/tmp";
# clean up
@@ -33,7 +30,7 @@ rmtree $tmpdir if -d $tmpdir;
mkdir $tmpdir;
chdir $tmpdir;
-system( $^X, "-I$FindBin::Bin/../lib", "$FindBin::Bin/../script/catalyst.pl", 'TestApp' );
+system( $^X, "-I$FindBin::Bin/../lib", '-MFile::Spec', '-e', "\@ARGV=('TestApp'); my \$devnull = File::Spec->devnull; open my \$fh, '>', \$devnull or die \"Cannot write to \$devnull: \$!\"; *STDOUT = \$fh; do \"$FindBin::Bin/../script/catalyst.pl\"");
chdir "$FindBin::Bin/..";
File::Copy::Recursive::dircopy( 't/lib', 't/tmp/TestApp/lib' );
@@ -46,8 +43,8 @@ my $port = 30000 + int rand( 1 + 10000 );
my( $server, $pid );
my @cmd = ($^X, "-I$FindBin::Bin/../lib", "-I$FindBin::Bin/lib",
- "$FindBin::Bin/../t/tmp/TestApp/script/testapp_server.pl", '-port',
- $port, '-restart');
+ "$FindBin::Bin/../t/tmp/TestApp/script/testapp_server.pl", '--port',
+ $port, '--restart');
$pid = open3( undef, $server, undef, @cmd )
or die "Unable to spawn standalone HTTP server: $!";
@@ -83,7 +80,7 @@ for ( 1 .. 20 ) {
# give the server time to notice the change and restart
my $count = 0;
my $line;
- while ( ( $line || '' ) !~ /can connect/ ) {
+ while ( ( $line || '' ) !~ /ttempting to restart the server/ ) {
# wait for restart message
$line = $server->getline;
sleep 0.1;
@@ -110,45 +107,6 @@ for ( 1 .. 20 ) {
sleep 1;
}
-# add errors to the file and make sure server does not die or restart
-NO_RESTART_ON_ERROR:
-for ( 1 .. 20 ) {
- my $index = rand @files;
- open my $pm, '>>', $files[$index]
- or die "Unable to open $files[$index] for writing: $!";
- print $pm "bleh";
- close $pm;
-
- my $count = 0;
- my $line;
-
- while ( ( $line || '' ) !~ /failed/ ) {
- # wait for restart message
- $line = $server->getline;
- sleep 0.1;
- if ( $count++ > 100 ) {
- fail "Server restarted";
- SKIP: {
- skip "Server didn't restart, no sense in checking response", 1;
- }
- next NO_RESTART_ON_ERROR;
- }
- };
-
- pass "Server refused to restart";
-
- if ( check_port( 'localhost', $port ) != 1 ) {
- die "Server appears to have died";
- }
- my $response = get("http://localhost:$port/action/default");
- like( $response, qr/Catalyst::Request/,
- 'Syntax error, no restart, request OK' );
-
- # give the server some time to reindex its files
- sleep 1;
-
-}
-
# multiple restart directories
# we need different options so we have to rebuild most
@@ -157,87 +115,11 @@ for ( 1 .. 20 ) {
kill 'KILL', $pid;
close $server;
-# pick next port because the last one might still be blocked from
-# previous server. This might fail if this port is unavailable
-# but picking the first one has the same problem so this is acceptable
-
-$port += 1;
-
-{ no warnings 'once'; $File::Copy::Recursive::RMTrgFil = 1; }
-File::Copy::Recursive::dircopy( 't/lib', 't/tmp/TestApp/lib' );
-
-# change various files
-@files = (
- "$FindBin::Bin/../t/tmp/TestApp/lib/TestApp/Controller/Action/Begin.pm",
- "$FindBin::Bin/../t/tmp/TestApp/lib/TestApp/Controller/Engine/Request/URI.pm",
-);
-
-my $app_root = "$FindBin::Bin/../t/tmp/TestApp";
-my $restartdirs = join ' ', map{
- "-restartdirectory $app_root/lib/TestApp/Controller/$_"
-} qw/Action Engine/;
-
-$pid = open3( undef, $server, undef,
- $^X, "-I$FindBin::Bin/../lib",
- "$FindBin::Bin/../t/tmp/TestApp/script/testapp_server.pl", '-port',
- $port, '-restart', $restartdirs )
- or die "Unable to spawn standalone HTTP server: $!";
-$server->blocking( 0 );
-
-
-# wait for it to start
-print "Waiting for server to start...\n";
-while ( check_port( 'localhost', $port ) != 1 ) {
- sleep 1;
-}
-
-MULTI_DIR_RESTART:
-for ( 1 .. 20 ) {
- my $index = rand @files;
- open my $pm, '>>', $files[$index]
- or die "Unable to open $files[$index] for writing: $!";
- print $pm "\n";
- close $pm;
-
- # give the server time to notice the change and restart
- my $count = 0;
- my $line;
-
- while ( ( $line || '' ) !~ /can connect/ ) {
- # wait for restart message
- $line = $server->getline;
- sleep 0.1;
- if ( $count++ > 100 ) {
- fail "Server restarted";
- SKIP: {
- skip "Server didn't restart, no sense in checking response", 1;
- }
- next MULTI_DIR_RESTART;
- }
- };
- pass "Server restarted with multiple restartdirs";
-
- $count = 0;
- while ( check_port( 'localhost', $port ) != 1 ) {
- # wait for it to restart
- sleep 0.1;
- die "Server appears to have died" if $count++ > 100;
- }
- my $response = get("http://localhost:$port/action/default");
- like( $response, qr/Catalyst::Request/, 'Non-error restart, request OK' );
-
- # give the server some time to reindex its files
- sleep 1;
-}
-
-# shut it down again
-
-kill 'KILL', $pid;
-close $server;
-
# clean up
rmtree "$FindBin::Bin/../t/tmp" if -d "$FindBin::Bin/../t/tmp";
+done_testing;
+
sub check_port {
my ( $host, $port ) = @_;
@@ -44,7 +44,7 @@ sub request {
TestApp::Controller::Action::Default->begin
TestApp::Controller::Action::Default->default
TestApp::View::Dump::Request->process
- TestApp->end
+ TestApp::Controller::Root->end
];
my $expected = join( ", ", @expected );
@@ -15,13 +15,13 @@ use Test::More;
sub test {}
}
-
+my $c = 0;
foreach my $class (qw/ CT RT /) {
my $class_name = 'NoAttributes::' . $class;
my $meta = $class_name->meta;
my $meth = $meta->find_method_by_name('test');
{
- local $TODO = "Known MX::MethodAttributes issue";
+ local $TODO = "Known MX::MethodAttributes issue" if $c++;
ok $meth->can('attributes'), 'method metaclass has ->attributes method for ' . $class;;
}
}